package com.colin.app.activity.senior.showfloat;

import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.colin.app.R;
import com.colin.app.activity.senior.SeniorContract;
import com.colin.app.activity.senior.SeniorPresenterImpl;
import com.colin.app.app.AppActivity;
import com.colin.app.bean.DemoBean;

public class ShowFloatActivity extends AppActivity implements SeniorContract.SeniorView {
    private SeniorContract.SeniorPresenter mSeniorPresenter = null;
    private Button button_show_float_0;
    private Button button_show_float_1;
    private Button button_show_float_2;
    private GuideView guideView;
    private GuideView guideView3;
    private GuideView guideView2;

    @Override
    protected void onDestroy() {
        if (null != mSeniorPresenter) {
            mSeniorPresenter.destroy();
            mSeniorPresenter = null;
        }
        super.onDestroy();
    }

    @Override
    public void initPresenter() {

        DemoBean demoBean = getIntent().getExtras().getParcelable("clazz");
        mSeniorPresenter = new SeniorPresenterImpl(this, this, demoBean);
    }

    @Override
    public int initViewLayoutID() {
        return R.layout.activity_show_float;
    }

    @Override
    public void initView() {
        this.button_show_float_0 = (Button) this.findViewById(R.id.button_show_float_0);
        this.button_show_float_1 = (Button) this.findViewById(R.id.button_show_float_1);
        this.button_show_float_2 = (Button) this.findViewById(R.id.button_show_float_2);
        initGuideView();
    }

    private void initGuideView() {
        final ImageView imageView = new ImageView(this);
        imageView.setImageResource(R.mipmap.img_new_task_guide);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        imageView.setLayoutParams(layoutParams);
        // 使用文字
        TextView text_guide_one = new TextView(this);
        text_guide_one.setText("我是引导2的文字解说");
        text_guide_one.setTextColor(getResources().getColor(R.color.white));
        text_guide_one.setTextSize(30);
        text_guide_one.setGravity(Gravity.CENTER);
        // 使用文字
        final TextView text_guide_two = new TextView(this);
        text_guide_two.setText("我是引导3的文字解说");
        text_guide_two.setTextColor(getResources().getColor(R.color.white));
        text_guide_two.setTextSize(30);
        text_guide_two.setGravity(Gravity.CENTER);

        guideView = GuideView.Builder
                .newInstance(this)
                .setTargetView(button_show_float_0)//设置目标
                .setCustomGuideView(imageView) //显示自定义控件
                .setDirction(GuideView.Direction.LEFT_BOTTOM)
                .setShape(GuideView.MyShape.CIRCULAR)   // 设置圆形显示区域，
                .setRadius(0)   // 设置圆形或矩形透明区域半径，默认是targetView的显示矩形的半径，如果是矩形，这里是设置矩形圆角大小
                .setBgColor(getResources().getColor(R.color.track_color))
                .build();

        guideView2 = GuideView.Builder
                .newInstance(this)
                .setTargetView(button_show_float_1)//设置目标
                .setCustomGuideView(text_guide_one) //显示自定义控件
                .setDirction(GuideView.Direction.BOTTOM)
                .setShape(GuideView.MyShape.ELLIPSE)   // 设置圆形显示区域，
                .setRadius(0)   // 设置圆形或矩形透明区域半径，默认是targetView的显示矩形的半径，如果是矩形，这里是设置矩形圆角大小
                .setBgColor(getResources().getColor(R.color.track_color))
                .build();

        guideView3 = GuideView.Builder
                .newInstance(this)
                .setTargetView(button_show_float_2)//设置目标
                .setCustomGuideView(text_guide_two) //显示自定义控件
                .setDirction(GuideView.Direction.RIGHT_BOTTOM)
                .setShape(GuideView.MyShape.RECTANGULAR)   // 设置圆形显示区域，
                .setRadius(80)   // 设置圆形或矩形透明区域半径，默认是targetView的显示矩形的半径，如果是矩形，这里是设置矩形圆角大小
                .setBgColor(getResources().getColor(R.color.track_color))
                .build();

        guideView.show();
    }

    @Override
    public void initData() {
        mSeniorPresenter.setData();
    }

    @Override
    public void initListener() {
        guideView.setOnclickListener(new GuideView.OnClickCallback() {
            @Override
            public void onClickedGuideView() {
                guideView.hide();
                guideView2.show();
            }
        });
        guideView2.setOnclickListener(new GuideView.OnClickCallback() {
            @Override
            public void onClickedGuideView() {
                guideView2.hide();
                guideView3.show();
            }
        });
        guideView3.setOnclickListener(new GuideView.OnClickCallback() {
            @Override
            public void onClickedGuideView() {
                guideView3.hide();
                guideView.show();
            }
        });
    }
}
